home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / tchar.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-13  |  717 b   |  46 lines

  1. /*
  2.    tchar: convert from an output format type back to the character
  3.    which represents it.
  4.  
  5.    Kenneth Ingham
  6.  
  7.    Copyright (C) 1988 The University of New Mexico
  8. */
  9.  
  10. #include "defs.h"
  11. #include "y.tab.h"
  12.  
  13. /*
  14.   structure used to map types back to to characters for printing out
  15. */
  16. struct type_char {
  17.     int type;
  18.     char c;
  19. };
  20.  
  21.  
  22. char
  23. tchar(type)
  24. int type;
  25. {
  26.     int i;
  27.     static struct type_char types[] = {
  28.         { STRING,     's'},
  29.         { INTEGER,    'd'},
  30.         { FLOAT,    'f'},
  31.         { KEY,        'k'},
  32.         { 0,        '\0'}
  33.     };
  34.  
  35.     for (i=0; types[i].type && types[i].type != type; i++)
  36.         ;
  37.  
  38.     if (types[i].type == NULL) {
  39.         fprintf(stderr, "Internal error, unknown output format ");
  40.         fprintf(stderr, "type %d\n", type);
  41.         exit(1);
  42.     }
  43.  
  44.     return types[i].c;
  45. }
  46.